package tw.twandroidproj.app.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import tw.twandroidproj.app.R;

import static android.support.v7.widget.RecyclerView.*;

/**
 * Created by Lin on 2016/5/15.
 */
public class SellerCenterActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private List<String> mDatas;
    private HomeAdapter mAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        setContentView(R.layout.seller_center_table);

        TabHost m = (TabHost)findViewById(R.id.tabhost);
        m.setup();

        LayoutInflater i=LayoutInflater.from(this);
        i.inflate(R.layout.seller_center_tab01, m.getTabContentView());
        i.inflate(R.layout.seller_center_tab02, m.getTabContentView());
        i.inflate(R.layout.seller_center_tab03, m.getTabContentView());
        m.addTab(m.newTabSpec("tab1").setIndicator("招聘中").setContent(R.id.seller_center_tab01_layout));
        m.addTab(m.newTabSpec("tab2").setIndicator("招聘成功").setContent(R.id.seller_center_tab02_layout));
        m.addTab(m.newTabSpec("tab2").setIndicator("招聘失败").setContent(R.id.seller_center_tab03_layout));


        initData();
        mRecyclerView = (RecyclerView) findViewById(R.id.seller_center_tab01_list);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(mAdapter = new HomeAdapter());
    }

    protected void initData()
    {
        mDatas = new ArrayList<String>();
        for (int i = 'A'; i < 'z'; i++)
        {
            mDatas.add("" + (char) i);
        }
    }

   public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.MyViewHolder>
    {

        @Override
        public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
        {
            MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
                    SellerCenterActivity.this).inflate(R.layout.seller_center_tab01_item, parent,
                    false));
            return holder;
        }

        @Override
        public void onBindViewHolder(MyViewHolder holder, int position)
        {
            holder.tv.setText(mDatas.get(position));
            holder.lookup=(Button)findViewById(R.id.job_lookup);
            holder.cancel=(Button)findViewById(R.id.job_cancel);

        }

        @Override
        public int getItemCount()
        {
            return mDatas.size();
        }


       public class MyViewHolder extends ViewHolder implements View.OnClickListener
        {

            TextView tv;
            Button lookup,cancel;
            LinearLayout linearLayout;
            public MyViewHolder(final View it)
            {
                super(it);
                tv = (TextView) it.findViewById(R.id.job_name);
                linearLayout=(LinearLayout)it.findViewById(R.id.seller_center_tab01_item_layout);
                linearLayout.setOnClickListener(this);
            }

            @Override
            public void onClick(View view) {
                Intent intent=new Intent(SellerCenterActivity.this,applicant_list.class);
                startActivity(intent);

                }

            }
        }
    }



